import React, { Component } from 'react';
import { withRouter } from 'react-router-dom';

class Cate extends Component {
  state = {
    list: []
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    this.setState({
      list: nextProps.list
    })
  }
  // 跳转到商品详情页
  request_goods(value) {
    console.log(value, 2589);
    this.props.history.push(`/home/message/goodsdetil/${value}`)
  }
  render() {
    return (
      <div>
        {this.state.list.map((item) => {
          return (
            <div key={item.id} >
              <h3>{item.name}</h3>
              <div className='right_list' >
                {item.subNavs.map((it) => {
                  return (
                    <div className='cunt' key={it.id} onClick={() => { this.request_goods(it.id) }}>
                      <img src={it.pic} alt="" />
                      <div className='tbs'>{it.name}</div>
                    </div>
                  )
                })}
              </div>
            </div>
          )
        })
        }
      </div >
    );
  }
}

export default withRouter(Cate);